import NProgress from "nprogress";

export default [
    {
        path: "/login",
        name: "login",
        component: () => import("@/views/Login/Login.vue"),
        meta: {
            hidden: true
        }
    },
    {
        path: "/register",
        name: "register",
        component: () => import("@/views/Register/Register.vue"),
        meta: {
            hidden: true
        }
    },
    {
        path: "/search/:keyword?",
        name: "search",
        component: () => import("@/views/Search/Search.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/home",
        name: "home",
        component: () => import("@/views/Home/Home.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/detail/:id",
        name: "detail",
        component: () => import("@/views/Detail/Detail.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/cart_success/:skuNum",
        name: "cart_success",
        component: () => import("@/views/CartSuccess/CartSuccess.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/shopcart",
        name: "shopcart",
        component: () => import("@/views/ShopCart/ShopCart.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/trade",
        name: "trade",
        component: () => import("@/views/Trade/Trade.vue"),
        meta: {
            hidden: false
        },
        beforeEnter(to, from, next) {
            if (from.path === "/shopcart") {
                next()
            } else {
                next(false)
                NProgress.done()
            }
        }
    },
    {
        path: "/pay",
        name: "pay",
        component: () => import("@/views/Pay/Pay.vue"),
        meta: {
            hidden: false
        },
        beforeEnter(to, from, next) {
            if (from.path === "/trade") {
                next()
            } else {
                next(false)
                NProgress.done()
            }
        }
    },
    {
        path: "/paysuccess",
        name: "paysuccess",
        component: () => import("@/views/PaySuccess/PaySuccess.vue"),
        meta: {
            hidden: false
        }
    },
    {
        path: "/center",
        name: "center",
        component: () => import("@/views/Center/Center.vue"),
        children: [
            {
                path: "/center",
                redirect: "/center/myorder"
            },
            {
                path: "/center/myorder",
                name: "myorder",
                component: () => import("@/views/Center/myOrder.vue")
            },
            {
                path: "/center/grouporder",
                name: "grouporder",
                component: () => import("@/views/Center/groupOrder.vue")
            }
        ],
        meta: {
            hidden: false
        },
    },
    {
        path: "/",
        redirect: "/home"
    }
]
